package ex_from_web;

			abstract class Vehicle {
	        //subclasses will inherit an attribute
	        int maxSpeed;
	        //subclasses must implement this method 
	        //(otherwise they have to be declared as abstract classes)
	        abstract void showMaxSpeed(); 
	        //subclass will have this method (through inheritance) as is (default implementation)
	        //or they may implement their own implementation (override a method)
	        int getWheelsNumber() {
	           return 4;
	        }
	  }
	   
	   /**Car IS-A Vehicle*/
	   class Car extends Vehicle {
	     public Car() {
	         maxSpeed = 180; 
	     }

	     public void showMaxSpeed() {
	        System.out.println("Car max speed: " + maxSpeed + " km/h");
	     }
	     //Car class will inherit getWheelsNumber() method from the parent class
	     //there is no need to override this method because default implementation
	     //is appropriate for Car class - 4 wheels
	   }
	   
	   /**Bus IS-A Vehicle*/
	   class Bus extends Vehicle {
	     public Bus() {
	         maxSpeed = 100; 
	     }
	     
	     public void showMaxSpeed() {
	        System.out.println("Bus max speed: " + maxSpeed + " km/h");
	     }
	     //Bus class will override this method because the default implementation
	     //is not appropriate for Bus class
	     public int getWheelsNumber() {
	         return 6;
	     }
	   }
		   
	   /**Bus IS-A Vehicle*/
	   class Tractor extends Vehicle {
	     public Tractor() {
	         maxSpeed = 40; 
	     }
	     
	     public void showMaxSpeed() {
		        System.out.println("Tractor max speed: " + maxSpeed + " km/h");
		     }
		     //Truck class will override this method because the default implementation
		     //is not appropriate for Bus class
		     public int getWheelsNumber() {
		         return 4;
		     }
		   }
	   /**Truck IS-A Vehicle*/
	   class Truck extends Vehicle {
	     public Truck() {
	         maxSpeed = 80;
	     }
	     
	     public void showMaxSpeed() {
	        System.out.println("Truck max speed: " + maxSpeed + " km/h");
	     }
	     //Truck class will override this method because the default implementation
	     //is not appropriate for Bus class
	     public int getWheelsNumber() {
	         return 10;
	     }
	   }

	   public class abstract_class_exercise {
	   
	   public static void main(String[] args) {
	     Vehicle car = new Car();
	     Vehicle bus = new Bus();
	     Vehicle truck = new Truck();
	     Vehicle tractor = new Tractor();
	     car.showMaxSpeed();
	     bus.showMaxSpeed();
	     truck.showMaxSpeed();
	     tractor.showMaxSpeed();
	     System.out.println("Wheels number-car:" + car.getWheelsNumber() + 
	             ", bus:" + bus.getWheelsNumber() + ", truck:" + truck.getWheelsNumber() + 
	             ", tractor:" + tractor.getWheelsNumber());
	   }
	}


